$(function () {
    var fn = ABUS.Fn;
    var param = window.__param__;

    $("#order_info").renderTemp(param);
    fn.get({
        url: "/leader/order/beforePay",
        data: {
            orderId: param.orderId
        },
        success: function (data) {
            if (data.result === 1) {
                if (data.data.costTotalFee === undefined) {
                    data.data = {
                        costTotalFee: 0,
                        payTotalFee: 0,
                        receivableFee: 0,
                        returnedFee: 0,
                        serviceTotalFee: 0
                    }
                }
                $("#pay_info").renderTemp(data.data);
                param.returnedFee = data.data.returnedFee;
                var serviceTotalFee = parseInt(data.data.serviceTotalFee?data.data.serviceTotalFee:0);
                var costTotalFee = parseInt(data.data.costTotalFee?data.data.costTotalFee:0);

                $(".receipt_1").on("touchend", function () {
                    fn.payment({
                        price:serviceTotalFee + costTotalFee,
                        onSubmit: function (el) {
                            fn.get({
                                url: "/leader/order/stoping",
                                data: {
                                    orderId:param.orderId
                                },
                                success: function (data) {
                                    if (data.result === 1) {
                                        fn.closeModal();
                                        fn.page_goto({
                                            url:"./zuzhang_banli_shouye.html"
                                        })
                                    }
                                }
                            })
                        },
                        onCancel:function () {
                            fn.closeModal();
                        }
                    })
                })
            }
        }
    });

});
